package com.yjz.proxy.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author :yuanJinZhong
 * @description:代理处理类！
 * @date :2018/4/26-11:54
 */
public class MyInvokeHandler implements InvocationHandler {

  /**
   * 拥有目标对象的引用
   */
  private Object obj;

  public MyInvokeHandler(Object obj) {
    this.obj = obj;
  }

  @Override
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    System.out.println("开始处理目标对象的方法");
    Object result = method.invoke(obj, args);
    System.out.println("结束处理目标对象的方法");
    return result;
  }
}
